package com.sdp.wx.db.wx_contract.service.impl;

import com.sdp.wx.db.wx_contract.entity.WxContract;
import com.sdp.wx.db.wx_contract.mapper.WxContractMapper;
import com.sdp.wx.db.wx_contract.service.IWxContractService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.math.BigDecimal;

import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zsp
 * @since 2024-01-05
 */
@Service
public class WxContractServiceImpl extends ServiceImpl<WxContractMapper, WxContract> implements IWxContractService {

	@Override
	public void removeWxContract(String contractCode) {
		LambdaQueryWrapper<WxContract> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(WxContract::getContractCode, contractCode);
		remove(queryWrapper);
		
	}

	@Override
	public void setPayAmountAndRatio(String contractCode,BigDecimal payAmount, BigDecimal payRatio) {
		LambdaQueryWrapper<WxContract> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(WxContract::getContractCode, contractCode);
		WxContract contract = getOne(queryWrapper,false);
		if(contract!=null) {
			contract.setPayAmount(payAmount);
			contract.setPayRatio(payRatio);
			updateById(contract);
		}
		
	}

}
